package com.management.controller;


import com.management.controller.form.AddPriorityForm;
import com.management.controller.form.ChangePriorityForm;
import com.management.controller.form.GetAllPriorityForm;
import com.management.controller.form.SelPriorityByNameForm;
import com.management.service.DefectPriorityService;
import com.management.utils.Result;
import io.lettuce.core.cluster.pubsub.api.sync.PubSubNodeSelection;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 龙世超
 * @since 2022-03-23
 */
@Api(tags = "优先级相关")
@RestController
@RequestMapping("/defectPriority")
public class DefectPriorityController {

    @Resource
    private DefectPriorityService defectPriorityService;

    /**
     * 分页获取所有优先级
     * @return
     */
    @ApiOperation("分页获取所有优先级")
    @PostMapping("getAllPriority")
    public Result getAllProority(@RequestBody GetAllPriorityForm getAllPriorityForm){
       Result result= defectPriorityService.findAllPriority(getAllPriorityForm);
        return result;
    }

    /**
     * 新增优先级
     * @param
     * @return
     */
    @ApiOperation("新增优先级")
    @PostMapping("addPriority")
    public Result addPriority(@RequestBody AddPriorityForm addPriorityForm){
       Result result= defectPriorityService.addPriority(addPriorityForm);
        return result;
    }

    /**
     * 改变优先级状态
     * @param priorityId 优先级ID
     * @return
     */
    @ApiOperation("改变优先级状态")
    @GetMapping("closePriority")
    public Result closePriority(Integer priorityId){

    Result result= defectPriorityService.closePriority(priorityId);
    return result;
    }

    /**
     * 检查优先级状态
     * @param priorityId
     * @return
     */
    @ApiOperation("检查优先级状态")
    @GetMapping("checkedPriorityState")
    public Result checkedPriorityState(Integer priorityId){
       Result result= defectPriorityService.checkPriorityState(priorityId);
       return result;
    }

    /**
     * 删除优先级
     * @param priorityId 优先级ID
     * @return
     */
    @ApiOperation("删除优先级")
    @GetMapping("delPriority")
    public Result delPriority(Integer priorityId){
       Result result= defectPriorityService.delPriority(priorityId);
       return result;
    }

    /**
     * 模糊查询优先级列表
     * @param selPriorityByNameForm 参数
     * @return
     */
    @ApiOperation("模糊查询优先级列表")
    @PostMapping("selByName")
    public Result selByName(@RequestBody SelPriorityByNameForm selPriorityByNameForm){
       Result result= defectPriorityService.findPriorityByName(selPriorityByNameForm);
        return result;
    }

    /**
     * 修改优先级名称
     * @param changePriorityForm 参数
     * @return
     */
    @ApiOperation("修改优先级名称")
    @PostMapping("changePriority")
    public Result changePriority(@RequestBody ChangePriorityForm changePriorityForm){
       Result result= defectPriorityService.changePriority(changePriorityForm);
        return result;
    }

    /**
     * 不分页获取所有优先级
     * @return
     */
    @ApiOperation("不分页获取所有优先级")
    @GetMapping("getAllPrioritys")
    public Result getAllPrioritys(){
       Result result= defectPriorityService.getAllPrioritys();
       return result;
    }
}

